//
//  THJCompanyInfoView.m
//  THJXHW
//
//  Created by 河南德艺 on 2017/11/4.
//  Copyright © 2017年 河南德艺. All rights reserved.
//

#import "THJCompanyInfoView.h"
#import "THJCompanyInfoCell.h"
@interface THJCompanyInfoView()<UITableViewDelegate,UITableViewDataSource>
{
    UITableView * _tableview;
    NSDictionary * infoDic;
}
@property(strong,nonatomic)UILabel * introduceLab;
@property(strong,nonatomic)UIImageView * cBannerImgV;
@end
@implementation THJCompanyInfoView
-(UILabel*)introduceLab{
    if(!_introduceLab){
        _introduceLab = [[UILabel alloc] init];
        _introduceLab.frame =  CGRectMake(10, 5, ScreenWidth - 20, 100);
        _introduceLab.numberOfLines = 0;
    }
    return  _introduceLab;
}
-(UIImageView*)cBannerImgV{
    if(!_cBannerImgV){
        _cBannerImgV = [[UIImageView alloc] init];
        _cBannerImgV.frame =  CGRectMake(10, 5, ScreenWidth - 20, 120);
    }
    return  _cBannerImgV;
}
-(instancetype)initWithDic:(NSDictionary*)dic{
    infoDic = dic;
    if(self = [super init]){
        [self setUI];
    }
    return self;
}
-(void)setUI{
    NSLog(@"关于-%@",infoDic);
    _tableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-240) style:UITableViewStylePlain];
    [self addSubview:_tableview];
    [_tableview registerNib:[UINib nibWithNibName:@"THJCompanyInfoCell" bundle:nil] forCellReuseIdentifier:@"info"];
    _tableview.delegate = self;
    _tableview.dataSource = self;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.row == 0){
        return 130;
    }else if (indexPath.row == 1){
        return 110;
    }
    else{
        return 275;
    }
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.row == 0){
        UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell1"];
        if(!cell){
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell1"];
        }
        [self.cBannerImgV sd_setImageWithURL:[NSURL URLWithString:infoDic[@"cbanner"]] placeholderImage:kGetImage(@"占位图")];
        NSLog(@"infoIDc-%@",infoDic);
        [cell.contentView addSubview:self.cBannerImgV];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else if(indexPath.row == 1){
        UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        if(!cell){
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
        }
        self.introduceLab.text = infoDic[@"introduce"];
        NSLog(@"infoIDc-%@",infoDic);
        [cell.contentView addSubview:self.introduceLab];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else{
        THJCompanyInfoCell * cell = [tableView dequeueReusableCellWithIdentifier:@"info" forIndexPath:indexPath];
        [cell updateContentWithDic:infoDic];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
}
@end
